package jianzhiOffer;

import java.util.HashSet;
import java.util.Set;

public class num03 {
    public int findRepeatNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        int ans = -1;
        for(int i = 0;i < nums.length;i ++) {
            if(!set.add(nums[i])) {
                ans = nums[i];
                break;
            }
            set.add(nums[i]);
        }
        return ans;
    }
}
